#include "builtin.h"

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

static void cd_func( char ** argv )
{
    if ( argv[1] == NULL ) {
        printf( "brash: cd: not enough argument\n" );
        return;
    }

    if ( chdir( argv[1] ) != 0 )
        printf( "brash: cd: error %d: %s\n", errno, argv[1] );
}

BuiltInCommand get_built_in( const char * command )
{
    if ( strcmp( "cd", command ) == 0 )
        return cd_func;

    return NULL;
}
